class Solution {
public:
    int longestConsecutive(vector<int>& nums) {
        unordered_set<int> st(nums.begin(), nums.end());
		// for(int num : nums)
		//   st.insert(num);
        int ans = 0;
        for(int e : st)
        {
            if(st.contains(e - 1))  continue;
            int count = 1;
            while(st.contains(e + 1))
            {
                ++e;
                ++count;
            }
            ans = max(ans, count);
        }
        return ans;
    }
};
